<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="">
        <input type="text" name="" id="input">
        <button id="btn">点击</button>
    </form>
    <script>
        
        /**
         * document.activeElement()
         * 始终包含当前拥有焦点的元素
         * 
         * document.hasFocus('element')
         * 判断元素是否获取焦点, 可以帮助确定用户是否在操作页面
        */

        const btn = document.getElementById("btn")
        const input = document.getElementById("input")
        input.focus()
        console.log(document.activeElement)
        
    </script>
</body>
</html>